package com.test.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.test.model.Product;

@Controller
@RequestMapping("/")
public class IndexController {

	@RequestMapping(value = "index")
	public String index() {
		return "index";
	}

	@RequestMapping(value = "index2")
	public String index2() {
		return "index2";
	}

	@RequestMapping(value = "loading")
	public String loading() {
		return "loading";
	}

	@RequestMapping(value = "fm")
	public ModelAndView ftlTest(ModelAndView model) {
		Map<String, Object> root = new HashMap<>();
		root.put("user", "Big Joe");
		Product latest = new Product();
		latest.setUrl("products/greenmouse.html");
		latest.setName("green mouse");
		root.put("latestProduct", latest);
		model.addObject("root", root);
		model.setViewName("ftlindex");
		return model;
	}

}
